data "google_client_config" "provider" {}

data "google_container_cluster" "my_cluster" {
  name     = "cluster-1"
  location = "us-central1-c"
}

provider "kubernetes-alpha" {
  host  = "https://${data.google_container_cluster.my_cluster.endpoint}"
  token = data.google_client_config.provider.access_token
  cluster_ca_certificate = base64decode(
    data.google_container_cluster.my_cluster.master_auth.0.cluster_ca_certificate,
  )
}

resource "kubernetes_manifest" "test-configmap" {
  provider = kubernetes-alpha

  manifest = {
    "apiVersion" = "serving.knative.dev/v1"
    "kind"       = "Service"
    "metadata" = {
      "name"      = "helloworld-go"
      "namespace" = "default"
    }
    "spec" = {
      "template" = {
        "spec" = {
          "containers" = [
            {
              "image" = "us-docker.pkg.dev/cloudrun/container/hello"
            }
          ]
        }
      }
    }
  }
}
